<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('区域管理')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<style>
    input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

    input[type="number"] {
        -moz-appearance: textfield;
    }


</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="dv">
    <form class="form-horizontal m" id="budget-edit" AUTOCOMPLETE="OFF">
        <input type="hidden" id="companyId" name="companyId">
        <input type="hidden" id="proId" name="proId">
        <input type="hidden" id="programId" name="programId">
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">前期产值：</label>
                    <div class="col-sm-8">
                        <input id="prePrice" name="prePrice" class="form-control" type="number"
                               placeholder="请输入前期产值">
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4 compBudget">全年预算（0）元</h4>
        <input type="hidden" name="planbudgetParam[0].total">
        <input type="hidden" name="planbudgetParam[0].type" value="0"/>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">一月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].janValue" class="form-control" type="number"
                               placeholder="请输入一月预算">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">二月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].febValue" class="form-control" type="number"
                               placeholder="请输入二月预算">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">三月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].marValue" class="form-control" type="number"
                               placeholder="请输入三月预算">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">四月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].aprValue" class="form-control" type="number"
                               placeholder="请输入四月预算">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">五月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].mayValue" class="form-control" type="number"
                               placeholder="请输入五月预算">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">六月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].junValue" class="form-control" type="number"
                               placeholder="请输入六月预算">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">七月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].julValue" class="form-control" type="number"
                               placeholder="请输入七月预算">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">八月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].augValue" class="form-control" type="number"
                               placeholder="请输入八月预算">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">九月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].sepValue" class="form-control" type="number"
                               placeholder="请输入九月预算">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">十月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].octValue" class="form-control" type="number"
                               placeholder="请输入十月预算">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">十一月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].novValue" class="form-control" type="number"
                               placeholder="请输入十一月预算">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">十二月预算：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[0].decValue" class="form-control" type="number"
                               placeholder="请输入十二月预算">
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4 compPlan">全年计划（0）元</h4>
        <input type="hidden" name="planbudgetParam[1].total">
        <input type="hidden" name="planbudgetParam[1].type" value="1"/>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">一月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].janValue" class="form-control" type="number"
                               placeholder="请输入一月计划">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">二月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].febValue" class="form-control" type="number"
                               placeholder="请输入二月计划">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">三月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].marValue" class="form-control" type="number"
                               placeholder="请输入三月计划">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">四月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].aprValue" class="form-control" type="number"
                               placeholder="请输入四月计划">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">五月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].mayValue" class="form-control" type="number"
                               placeholder="请输入五月计划">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">六月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].junValue" class="form-control" type="number"
                               placeholder="请输入六月计划">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">七月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].julValue" class="form-control" type="number"
                               placeholder="请输入七月计划">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">八月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].augValue" class="form-control" type="number"
                               placeholder="请输入八月计划">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">九月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].sepValue" class="form-control" type="number"
                               placeholder="请输入九月计划">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">十月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].octValue" class="form-control" type="number"
                               placeholder="请输入十月计划">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">十一月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].novValue" class="form-control" type="number"
                               placeholder="请输入十一月计划">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">十二月计划：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[1].decValue" class="form-control" type="number"
                               placeholder="请输入十二月计划">
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4 accFinish">全年滚动（0）元</h4>
        <input type="hidden" name="planbudgetParam[2].total">
        <input type="hidden" name="planbudgetParam[2].type" value="2"/>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">一月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].janValue" class="form-control" type="number"
                               placeholder="请输入一月滚动">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">二月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].febValue" class="form-control" type="number"
                               placeholder="请输入二月滚动">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">三月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].marValue" class="form-control" type="number"
                               placeholder="请输入三月滚动">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">四月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].aprValue" class="form-control" type="number"
                               placeholder="请输入四月滚动">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">五月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].mayValue" class="form-control" type="number"
                               placeholder="请输入五月滚动">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">六月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].junValue" class="form-control" type="number"
                               placeholder="请输入六月滚动">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">七月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].julValue" class="form-control" type="number"
                               placeholder="请输入七月滚动">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">八月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].augValue" class="form-control" type="number"
                               placeholder="请输入八月滚动">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">九月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].sepValue" class="form-control" type="number"
                               placeholder="请输入九月滚动">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">十月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].octValue" class="form-control" type="number"
                               placeholder="请输入十月滚动">
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">十一月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].novValue" class="form-control" type="number"
                               placeholder="请输入十一月滚动">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">十二月滚动：</label>
                    <div class="col-sm-8">
                        <input name="planbudgetParam[2].decValue" class="form-control" type="number"
                               placeholder="请输入十二月滚动">
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4"></h4>
        <div class="form-group">
            <div class="col-sm-12">
                <div class="col-sm-6">
                    <label class="col-sm-4 control-label">材差及签证调整额：</label>
                    <div class="col-sm-8">
                        <input id="poorQuality" name="poorQuality" class="form-control" type="number"
                               placeholder="请输入材差及签证调整额">
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>


<script th:inline="javascript">
    var companyId = [[${companyId}]];
    var proId = [[${proId}]];
    var programId = [[${programId}]];
    var prefix = ctx + "planbudget";
    $(function () {
        $("#companyId").val(companyId);
        $("#proId").val(proId);
        $("#programId").val(programId);
        var compBudget;//全年预算
        var compPlan;//全年计划
        var accFinish;//全年完成
        $.ajax({
            url: prefix + '/queryBudgeByProgramId',
            data: {
                programId: programId
            },
            type: 'POST',
            success: function (data) {
                //预算
                $("input[name='planbudgetParam[0].janValue']").val(data[0].janValue);
                $("input[name='planbudgetParam[0].febValue']").val(data[0].febValue);
                $("input[name='planbudgetParam[0].marValue']").val(data[0].marValue);
                $("input[name='planbudgetParam[0].mayValue']").val(data[0].mayValue);
                $("input[name='planbudgetParam[0].julValue']").val(data[0].julValue);
                $("input[name='planbudgetParam[0].sepValue']").val(data[0].sepValue);
                $("input[name='planbudgetParam[0].novValue']").val(data[0].novValue);
                $("input[name='planbudgetParam[0].aprValue']").val(data[0].aprValue);
                $("input[name='planbudgetParam[0].junValue']").val(data[0].junValue);
                $("input[name='planbudgetParam[0].augValue']").val(data[0].augValue);
                $("input[name='planbudgetParam[0].octValue']").val(data[0].octValue);
                $("input[name='planbudgetParam[0].decValue']").val(data[0].decValue);
                $("input[name='planbudgetParam[0].total']").val(data[0].total);
                //计划
                $("input[name='planbudgetParam[1].janValue']").val(data[1].janValue);
                $("input[name='planbudgetParam[1].febValue']").val(data[1].febValue);
                $("input[name='planbudgetParam[1].marValue']").val(data[1].marValue);
                $("input[name='planbudgetParam[1].mayValue']").val(data[1].mayValue);
                $("input[name='planbudgetParam[1].julValue']").val(data[1].julValue);
                $("input[name='planbudgetParam[1].sepValue']").val(data[1].sepValue);
                $("input[name='planbudgetParam[1].novValue']").val(data[1].novValue);
                $("input[name='planbudgetParam[1].aprValue']").val(data[1].aprValue);
                $("input[name='planbudgetParam[1].junValue']").val(data[1].junValue);
                $("input[name='planbudgetParam[1].augValue']").val(data[1].augValue);
                $("input[name='planbudgetParam[1].octValue']").val(data[1].octValue);
                $("input[name='planbudgetParam[1].decValue']").val(data[1].decValue);
                $("input[name='planbudgetParam[1].total']").val(data[1].total);
                //滚动
                $("input[name='planbudgetParam[2].janValue']").val(data[2].janValue);
                $("input[name='planbudgetParam[2].febValue']").val(data[2].febValue);
                $("input[name='planbudgetParam[2].marValue']").val(data[2].marValue);
                $("input[name='planbudgetParam[2].mayValue']").val(data[2].mayValue);
                $("input[name='planbudgetParam[2].julValue']").val(data[2].julValue);
                $("input[name='planbudgetParam[2].sepValue']").val(data[2].sepValue);
                $("input[name='planbudgetParam[2].novValue']").val(data[2].novValue);
                $("input[name='planbudgetParam[2].aprValue']").val(data[2].aprValue);
                $("input[name='planbudgetParam[2].junValue']").val(data[2].junValue);
                $("input[name='planbudgetParam[2].augValue']").val(data[2].augValue);
                $("input[name='planbudgetParam[2].octValue']").val(data[2].octValue);
                $("input[name='planbudgetParam[2].decValue']").val(data[2].decValue);
                $("input[name='planbudgetParam[2].total']").val(data[2].total);

                $("#prePrice").val(data[0].prePrice);
                $("#poorQuality").val(data[0].poorQuality);
                $(".compBudget").text("全年预算（" + $("input[name='planbudgetParam[0].total']").val() + "）元");
                $(".compPlan").text("全年计划（" + $("input[name='planbudgetParam[1].total']").val() + "）元");
                $(".accFinish").text("滚动计划（" + $("input[name='planbudgetParam[2].total']").val() + "）元");
            }
        })


        $("input").change(function () {
            compBudget = Number($("input[name='planbudgetParam[0].janValue']").val()) + Number($("input[name='planbudgetParam[0].febValue']").val()) +
                Number($("input[name='planbudgetParam[0].marValue']").val()) + Number($("input[name='planbudgetParam[0].aprValue']").val()) +
                Number($("input[name='planbudgetParam[0].mayValue']").val()) + Number($("input[name='planbudgetParam[0].junValue']").val()) +
                Number($("input[name='planbudgetParam[0].julValue']").val()) + Number($("input[name='planbudgetParam[0].augValue']").val()) +
                Number($("input[name='planbudgetParam[0].sepValue']").val()) + Number($("input[name='planbudgetParam[0].octValue']").val()) +
                Number($("input[name='planbudgetParam[0].novValue']").val()) + Number($("input[name='planbudgetParam[0].decValue']").val());

            compPlan = Number($("input[name='planbudgetParam[1].janValue']").val()) + Number($("input[name='planbudgetParam[1].febValue']").val()) +
                Number($("input[name='planbudgetParam[1].marValue']").val()) + Number($("input[name='planbudgetParam[1].aprValue']").val()) +
                Number($("input[name='planbudgetParam[1].mayValue']").val()) + Number($("input[name='planbudgetParam[1].junValue']").val()) +
                Number($("input[name='planbudgetParam[1].julValue']").val()) + Number($("input[name='planbudgetParam[1].augValue']").val()) +
                Number($("input[name='planbudgetParam[1].sepValue']").val()) + Number($("input[name='planbudgetParam[1].octValue']").val()) +
                Number($("input[name='planbudgetParam[1].novValue']").val()) + Number($("input[name='planbudgetParam[1].decValue']").val());

            accFinish = Number($("input[name='planbudgetParam[2].janValue']").val()) + Number($("input[name='planbudgetParam[2].febValue']").val()) +
                Number($("input[name='planbudgetParam[2].marValue']").val()) + Number($("input[name='planbudgetParam[2].aprValue']").val()) +
                Number($("input[name='planbudgetParam[2].mayValue']").val()) + Number($("input[name='planbudgetParam[2].junValue']").val()) +
                Number($("input[name='planbudgetParam[2].julValue']").val()) + Number($("input[name='planbudgetParam[2].augValue']").val()) +
                Number($("input[name='planbudgetParam[2].sepValue']").val()) + Number($("input[name='planbudgetParam[2].octValue']").val()) +
                Number($("input[name='planbudgetParam[2].novValue']").val()) + Number($("input[name='planbudgetParam[2].decValue']").val());

            $("input[name='planbudgetParam[0].total']").val(compBudget);
            $(".compBudget").text("全年预算（" + compBudget + "）元");
            $("input[name='planbudgetParam[1].total']").val(compPlan);
            $(".compPlan").text("全年计划（" + compPlan + "）元");
            $("input[name='planbudgetParam[2].total']").val(accFinish);
            $(".accFinish").text("滚动计划（" + accFinish + "）元");
        })

    })


    function submitHandler() {

        var data = $("#budget-edit").serializeArray();
        $.operate.save(prefix + '/editBudget', data);
        parent.refresh();
    }

</script>
</body>
</html>